import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from './network'
import store from 'store'
import moment from 'moment'

import './plugins'
import 'styles/base.scss'
import 'styles/iconfont.css'
import 'lib-flexible'

import HmNav from 'components/hm-nav.vue'
import HmHeader from 'components/hm-header.vue'

Vue.prototype.$axios = axios

Vue.prototype.$bus = new Vue()

Vue.config.productionTip = false

/**
 * 全局组件注册
 */
Vue.component('HmNav', HmNav)
Vue.component('HmHeader', HmHeader)

Vue.filter('imgUrl', (value) => {
  return axios.defaults.baseURL + value
})

Vue.filter('formatDate', (value, str = 'YYYY-MM-DD') => {
  return moment(value).format(str)
})

Vue.directive('focus', {
  inserted: function (el) {
    el.focus()
  }
})

moment.locale('zh-cn')

Vue.filter('fromNow', (value) => {
  return moment(value).fromNow()
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
